{%- if site.data.analytics.google.id -%}
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.data.analytics.google.id }}"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', '{{ site.data.analytics.google.id }}');
    </script>
{%- endif -%}

{%- if site.data.analytics.matomo.site_id -%}
    <script type="text/javascript">
        var analyticsAPI = {
            id: '{{ site.data.analytics.matomo.site_id }}',
            url: '{{ site.data.analytics.matomo.url }}',
            token: '{{ site.data.analytics.matomo.token }}'
        };
        var _paq = _paq || [];
        _paq.push(["setDomains", [{% for domain in site.data.analytics.matomo.domains %}"{{ domain }}"{% unless forloop.last %}, {% endunless %}{% endfor %}]]);
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function() {
            var u="{{ site.data.analytics.matomo.url }}";
            _paq.push(['setTrackerUrl', u+'matomo.php']);
            _paq.push(['setSiteId', '{{ site.data.analytics.matomo.site_id }}']);
            var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
            g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
        })();
    </script>
{%- endif -%}